package com.sasis.webapp.task;

import java.util.Iterator;
import java.util.List;

import javax.servlet.ServletContext;

public class TaskThread extends Thread {
	
	private List tasks;
	
	private ServletContext context;
	
	public TaskThread(List tasks, ServletContext context) {
		this.tasks = tasks;
		this.context = context;
	}
	
	public void run() {
		for (Iterator iterator = tasks.iterator(); iterator.hasNext(); ) {
			Task task = (Task)iterator.next();
			try {
				task.doTask(context);
			} catch (Exception ex) {
				ex.printStackTrace();
			}
		}
		tasks.clear();
		tasks = null;
		context = null;
	}

}
